#!/bin/sh
ipaddr="`/sbin/ifconfig eth0 | grep inet | sed '2,$d' | awk -F " " '{print $2}' | awk -F ":" '{print $2}'`"
FETION_PATH=/home/yangrong
 if [ $# -ge 1 ]; then
      msg=$1
 else
     read  -p "please enter :" msg
 fi
echo $msg 
echo `date` 
sendMail() {
if [ -f "$FETION_PATH/tosendlist.txt" ] && [ -f "$FETION_PATH/mail.jar" ];then
    for toSend in `cat $FETION_PATH/tosendlist.txt`
        do
            java -jar $FETION_PATH/mail.jar -msg "$msg" -to "$toSend" -sub "$ipaddr"
        done
else
    echo "Download needed files error" && exit 1
fi
}
sendMail
echo 'send end!'
exit 0
